Component({
  options:{
    multipleSlots: true,
    styleIsolation: 'isolated'
  },
  properties: {
    // 接收父组件传递的数据
    options: Array,
    value: {
      type: Array,
      observer(newVal){
        this.setData({
          currentValue: newVal
        })
      }
    },
  },
  data: {
    show: false,
    currentValue: [0],
    preValue: [0]
  },
  methods: {
    handleOpenDialog(){
      const that = this
      const preValue = this.data.preValue
      const obj = {
        show: true,
        currentValue: preValue
      }
      if(that.properties.value?.length) {
        obj.currentValue = that.properties.value
      }
      this.setData({
        ...obj
      })
    },
    handleCloseDialog(){
      this.setData({
        show:false
      })
    },
    handleCancel(){
      this.setData({
        show:false
      })
    },
    handleConfirm(){
      const value = this.data.currentValue
      this.triggerEvent('change',{
        value,
        info: this.properties.options[value[0]]
      })
      this.setData({
        show: false,
        currentValue: value,
        preValue: value
      })
    },
    bindChange(e){
      const val = e.detail.value;
      console.log('val',val);
      this.setData({
        currentValue: val
      })
    }
  },
  // 可选：生命周期
  lifetimes: {
    attached() {},
  }
});